<?php
class Member_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
		$this->load->database() ;
	}
	
	public function login($username, $pwd=''){
//		$sql = "SELECT * FROM member WHERE username='$username' AND pwd='$pwd'";
		
		$data = $this->db->get_where('member', array('username'=>$username, 'pwd'=>$pwd));
		return $data->row_array();
	}
	
	public function username_check($str, $type='username'){
		$data = $this->db->query("select count(*) as cnt from member where {$type}='$str'");
		return $data->row_array();
	}
	
	public function teacher_list(){
		$sql = "SELECT * FROM member m
				LEFT JOIN teacher t 
				ON m.id = t.uid";
		$data = $this->db->query($sql);
		return $data;
	}
	
}